<!DOCTYPE html>
<html>  
  <head>
    <title>{$web_title}</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
	<script type="text/javascript" src="/public/novel/js/jquery.min.js"></script>
	<script type="text/javascript" src="/public/layer/layer.js"></script>
	<script src="/public/novel/flexible/flexible_css.js"></script>
	<script src="/public/novel/flexible/flexible.js"></script>
	<link href="/public/activity/template3/v3.7832bce3.css" rel="stylesheet">
  </head>
  
  <body>
    <div id="root">
      <div class="page">
        <div class="portal">
          <div class="inner">
            <div class="header"></div>
			
            <div class="title1">充{$info.price}元多送{$info.giveegold}书币</div>
            <div class="title2">共得{$info.egold}阅读币+{$info.giveegold}书币</div>
			<div class="slogan btn-recharge" data-money='{$info.price}' data-activityid='{$info.id}' data-payid='{$info.payid}' data-userlimit='{$info.user_limit}'></div>
			
            <div class="timer settime" endTime="{notempty name="info.endtime"}{$info.endtime|date='Y-m-d H:i:s',###}{/notempty}">
              <div>0天0小时0分0秒</div></div>
            <div class="rules">
              <div>1.此充值为阅读币充值；</div>
              <div>2.阅读币为虚拟物品，不支持退货；</div>
              <div>3.本次充值活动每人仅限参加1次；</div>
          </div>
          <div class="footer"></div>
        </div>
      </div>
    </div>
	<script type="text/javascript">
		var loginurl = "{$domain}/login?backurl={$backurl}";
		var jumpurl = "{$domain}/personal/info";
		var cancelurl = window.location.href;
		var login = {$uid|default=0};
		var payurl = "{:config('agent_payurl')}";
		var pay_change = {:config('pay_change')};
		var paylimit = {$paylimit};
		var paytype = {$paytype};
		
		$(function(){
			$('.btn-recharge').click(function(){
				var money = $(this).data('money');
				var payid = $(this).data("payid");
				var userlimit = $(this).data("userlimit");
				var activityid = $(this).data('activityid');
				var endtime = {$info.endtime|default=0};
				var nowtime = new Date().getTime().toString();
				nowtime = nowtime.substr(0,10);

				if (paylimit>0)
				{
					layer.msg("你已经参加过本次活动!");
					return false;
				}
				if (paytype==1)
				{
					layer.msg("你不是已充值用户，不能参加本次活动!");
					return false;
				}
				if (paytype==2)
				{
					layer.msg("你不是未充值用户，不能参加本次活动!");
					return false;
				}

				if(endtime >nowtime){
					var ua = navigator.userAgent.toLowerCase();
					if(ua.match(/MicroMessenger/i)=="micromessenger") {  
						if (pay_change==1)
						{
							var url = payurl+'/pay/pay.html?egold='+money+'&type=4&activityid='+activityid+'&isactivity=1&jumpurl='+jumpurl+'&cancelurl='+cancelurl+'&payid='+payid+'&userlimit='+userlimit;
						}else{
							var url = payurl+'/pay/thirdpay.html?egold='+money+'&type=4&activityid='+activityid+'&isactivity=1&jumpurl='+jumpurl+'&cancelurl='+cancelurl+'&payid='+payid+'&userlimit='+userlimit;
						}
					} else {  
						var url = payurl+'/alipay/pay.html?egold='+money+'&type=4&activityid='+activityid+'&isactivity=1&jumpurl='+jumpurl+'&cancelurl='+cancelurl+'&payid='+payid+'&userlimit='+userlimit;
					}

					if(login)
					{
						document.location.href=url
					}else{
						document.location.href=loginurl	
					}
				}else{
					layer.msg("活动已结束!");
				}

			})

		})
		function updateEndTime()
		{
			var date = new Date();
			var time = date.getTime(); //当前时间距1970年1月1日之间的毫秒数
			var endDate =$('.settime').attr("endTime"); //结束时间字符串
			var html='';
			//转换为时间日期类型
			//console.log(endDate);
			var endDate1 = eval('new Date(' + endDate.replace(/\d+(?=-[^-]+$)/,
			function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) +')');
				var endTime = endDate1.getTime(); //结束时间毫秒数
				var lag = (endTime - time) / 1000; //当前时间和结束时间之间的秒数
				if(lag > 0)
				{
					var second = Math.floor(lag % 60); 
					var minite = Math.floor((lag / 60) % 60);
					var hour = Math.floor((lag / 3600) % 24);
					var day = Math.floor((lag / 3600) / 24);
					
					html +=day+'天';
					html +=hour+'时';
					html +=minite+'分';
					html +=second+'秒';
					$('.settime div').html(html);
				}else{
					//$(this).removeClass("settime");
					//alert($(this).attr("id"));
					$('.settime idv').html('已经结束啦！');
				}

			setTimeout("updateEndTime()",1000);

		}
		$(function(){
			updateEndTime();
		});
	</script>	
   
  </body>

</html>